package com.cqeec.gams.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cqeec.gams.dao.RoleMapper;
import com.cqeec.gams.entity.Role;

/**
 * 角色服务类。
 * 
 * @author 唐礼飞
 *
 */
@Service
public class RoleServiceImpl implements RoleService {
	@Autowired
	private RoleMapper roleMapper;

	@Override
	public long count() {
		return roleMapper.count();
	}

	@Override
	public Role findById(String id) {
		return roleMapper.findById(id);
	}

	@Override
	public List<Role> findAll() {
		return roleMapper.findAll();
	}

	@Override
	public List<Role> findPage(int startRowNumber, int pageSize) {
		return roleMapper.findPage(startRowNumber, pageSize);
	}

	@Override
	public void insert(Role entity) {
		roleMapper.insert(entity);
	}

	@Override
	public void update(Role entity) {
		roleMapper.update(entity);
	}

	@Override
	public void delete(String id) {
		roleMapper.delete(id);
	}

	@Override
	public long count(Role role) {
		return roleMapper.countByLikeName("%" + role.getName() + "%");
	}

	@Override
	public List<Role> findPage(int startRowNumber, int pageSize, Role role) {
		return roleMapper.findPageByLikeName(startRowNumber, pageSize, "%" + role.getName() + "%");
	}

}
